<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="net.sureon.biz.CompanyBO"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>费用充值</title>
	<script type="text/javascript">
		function validateForm(myForm) {
			if(myForm.siteURL.value == "") {
				alert('公司简称必填');
				return false;
			}
			if(myForm.amount.value == "") {
				alert('充值金额必填');
				return false;
			} else {
				if(isNaN(myForm.amount.value)) {
					alert('充值金额必须是数字');
					return false;
				}
			}
			return true;
		}
		function checkDate() {
		if(document.getElementById("startDate").value == "" || document.getElementById("endDate").value == "") {
			return true;
		}
		sd=document.getElementById("startDate").value;//取得表单填写的时间字符串
		var startDate=new Date(sd.replace(/-/g, "/")); //将表单字符转换成时间类型
		
		ed = document.getElementById("endDate").value;//取得表单填写的时间字符串
		var endDate = new Date(ed.replace(/-/g, "/"));
		
		//用当前时间与表单里的时间比较
		if(endDate.getTime()-startDate.getTime() < 0)
		{ 
			alert("结束日期不能够小于开始日期");
			return false;
		} 
		return true;
	}
	</script>
</head>

<body>
<jsp:include page="systemHeader.jsp"></jsp:include>
<table cellpadding="0" cellspacing="0" class="style5">
	<tr>
		<td colspan="2">
		<table cellpadding="0" cellspacing="0" class="style5">
			<tr>
				<td style="text-align: left" bgcolor="#FFFBD6" class="style6">
				<table id="ctl00_ContentPlaceHolder1_Menu1"
					class="ctl00_ContentPlaceHolder1_Menu1_2" cellpadding="0"
					cellspacing="0" border="0">
					<tr>
						<td onmouseover="Menu_HoverStatic(this)"
							onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)"
							id="ctl00_ContentPlaceHolder1_Menu1n0">
						<table 						
							class="ctl00_ContentPlaceHolder1_Menu1_4 ctl00_ContentPlaceHolder1_Menu1_9"
							cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr>
								<td style="white-space: nowrap;"><a
									class="ctl00_ContentPlaceHolder1_Menu1_1 ctl00_ContentPlaceHolder1_Menu1_3 ctl00_ContentPlaceHolder1_Menu1_8"
									href="<%=request.getContextPath() %>/sysAdmin/costChange.do">费用充值</a></td>
							</tr>
						</table>
						</td>
						<td style="width: 3px;"></td>
						<td onmouseover="Menu_HoverStatic(this)"
							onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)"
							id="ctl00_ContentPlaceHolder1_Menu1n1">
						<table cellpadding="0"
							cellspacing="0" border="0" width="100%">
							<tr>
								<td style="white-space: nowrap;"><a
									class="ctl00_ContentPlaceHolder1_Menu1_1 ctl00_ContentPlaceHolder1_Menu1_3"
									href="<%=request.getContextPath() %>/sysAdmin/sysConsumeRecord.do">消费记录</a></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" style="color: #333333; width: 100%; border-collapse: collapse; font-size: small; font-family: Arial">
  <tr>
  	<td>
  							<%
  								List<CompanyBO> list = (List<CompanyBO>)request.getAttribute("siteURLDropDownDisplayList");
  							 %>
							
							<form action="<%=request.getContextPath() %>/sysAdmin/costChange.do" method="post" onsubmit="return checkDate();">
								选择日期:<input type="text" size="7" id="startDate" name="startDate" value="${requestScope.startDate }" />&nbsp;&nbsp;
										<input type="text" size="7" id="endDate" name="endDate" value="${requestScope.endDate }" />&nbsp;&nbsp;
								公司简称:	
								 
										<select name="companyID" value="">
												<option value="-1">---请选择</option>
												<%
													for(CompanyBO company : list) {
													long companyID = -1;
													try {
														companyID = (Long)request.getAttribute("companyID");
													} catch(Exception e) {
													}
												 %>
												<option value="<%=company.getCompanyID() %>" <%=companyID == company.getCompanyID() ? "selected" : "" %>><%=company.getCompanyVO().getSiteURL() %></option>
												<%
													}
												 %>
										<input type="hidden" name="filter" value="true" />
										<input type="submit" value="过滤" />
							</form>
						</td>
  </tr>
  <tr>
    <td colspan="2"><div align="center">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">

        <tr>
          <td colspan="3"><div align="left">
          
              <table width="100%" border="0" cellpadding="4" cellspacing="0" bordercolor="#0000FF"
              style="color: #333333; width: 100%; border-collapse: collapse; font-size: small; font-family: Arial">
                <tr style="color: White; background-color: #507CD1; font-weight: bold;" align="center">
                  <th scope="col">公司全称</th>
                  <th scope="col" >公司英文简写</th>
                  <th scope="col">充值金额</th>
                  <th scope="col">消费金额</th>
                  <th scope="col">余额</th>
                  <th scope="col">经办日期</th>
                  <th scope="col">备注</th>
                </tr>
               <c:forEach var="balanceOperation" items="${requestScope.BalanceOperationDisplayResult}" varStatus="rowCounter">
               <c:choose>
						<c:when test="${rowCounter.count % 2 == 0}">
							<c:set var="bgColor" scope="page" value="#EFF3FB;" />
						</c:when>
						<c:otherwise>
							<c:set var="bgColor" scope="page" value="#FFFFFF;" />
						</c:otherwise>
					</c:choose> 
                <tr style="background-color: ${bgColor}"  align="center">
                  <td >${balanceOperation.companyFullName }</td>

                  <td>${balanceOperation.siteURL }</td>
                  <td>
					<c:choose>
						<c:when test="${balanceOperation.operationType == 'Save'}">
							${balanceOperation.amount }
						</c:when>
						<c:otherwise>
							&nbsp;&nbsp;
						</c:otherwise>
					</c:choose>	                  
                  </td>
                  <td>
					<c:choose>
						<c:when test="${balanceOperation.operationType == 'Consume'}">
							${balanceOperation.amount }
						</c:when>
						<c:otherwise>
							&nbsp;&nbsp;
						</c:otherwise>
					</c:choose>
				  </td>
                  <td>${balanceOperation.balance }</td>
                  <td><fmt:formatDate value="${balanceOperation.operationDate}" timeStyle="date" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                  <td>${balanceOperation.comments }</td>
                  </tr>
                </c:forEach>  
             </table>
          </div></td>
        </tr>
          <td>&nbsp;</td>

          <td></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3"><hr /></td>
        </tr>

        <tr>
          <td colspan="3">&nbsp;</td>
        </tr>
      <form id="form2" name="costForm" method="post" action="<%=request.getContextPath() %>/sysAdmin/costChange.do" onsubmit="return validateForm(this);">  
        <tr>
          <td colspan="3"><div align="center">
              <table align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td><div align="right">公司英文简写(*)：</div></td>
                  <td><div align="left">
										<select name="siteURL" value="">
												<option value="-1">---请选择</option>
												<%
												List<CompanyBO> theList = (List<CompanyBO>)request.getAttribute("siteURLDropDownDisplayList");
													for(CompanyBO company : theList) {
													String siteURL = "";
													try {
														siteURL = (String) request.getAttribute("siteURL");
													} catch(Exception e) {
													}
												 %>
												<option value="<%=company.getCompanyVO().getSiteURL() %>" <%=company.getCompanyVO().getSiteURL().equals(siteURL) ? "selected" : "" %>><%=company.getCompanyVO().getSiteURL() %></option>
												<%
													}
												 %>
                  </div></td>
                  </tr>
                <tr>
                  <td><div align="right">充值金额(*)：</div></td>
                  <td><div align="left">
                    <input id="ctl00_ContentPlaceHolder1_TextBox3" name="amount" />
                  </div></td>
                </tr>
                <tr>
                  <td><div align="right">备注：</div></td>

                  <td><div align="left">

                    <textarea id="ctl00$ContentPlaceHolder1$TextBox3" name="comments" rows=6 cols="50"></textarea>
                  </div></td>
                  </tr>
                
                <tr>
                  <td colspan="2"><div align="center">
                  	  <input type="hidden" name="operationType" value="Save" />
                  	  <input type="hidden" name="status" value="" />
                      <input type="submit" name="cost" value="充 值" />
                  </div></td>

                </tr>
             </form>
              </table>
          </div>
              <div align="center"></div></td>
        </tr>
      </table>
    <!-- InstanceEndEditable --></div></td>
  </tr>
</table>

</body>
<!-- InstanceEnd --></html>
